<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

  <c:if test="${hour != appointEndTime[0]-1 or isEndHour}">
    <div class="item">
      <c:set var="amount" value="${remainCoaches[halfhour]}"/>
      <c:set var="roomRecord" value="${roomRecords[halfhour] == null ? 0 : roomRecords[halfhour]}"/>
      <c:set var="commonRecord" value="${commonRecords[halfhour] == null ? 0 : commonRecords[halfhour]}"/>
      <c:set var="couldAppoint" value="${(currentSite.roomLimit.roomLimit - roomRecord > 0 && amount > 0) || (currentSite.roomLimit.commonLimit - commonRecord > 0 && amount > 0)}"/>
      <a href="javascript:void(0);" data-hour="${hourPerfix}${hour}:30" class="${couldAppoint ? 'booking-btn' : ''}">
        <p class="time">
          ${hourPerfix}${hour}:30~${afterhourPerfix}${hour + 1}:30<br/>
          <c:if test="${currentSite.roomLimit.roomLimit > 0}">
           私人区域：${currentSite.roomLimit.roomLimit - roomRecord < amount ? 
                    (currentSite.roomLimit.roomLimit - roomRecord > 0 ? currentSite.roomLimit.roomLimit - roomRecord : 0) : 
                    (amount > 0 ? amount : 0)}<br>
         </c:if>
         <c:if test="${currentSite.roomLimit.commonLimit > 0}">
           ${currentSite.fuxing ? '米域' : '公共区域' }：${currentSite.roomLimit.commonLimit - commonRecord < amount ? 
                     (currentSite.roomLimit.commonLimit - commonRecord > 0 ? currentSite.roomLimit.commonLimit - commonRecord : 0) : 
                     (amount > 0 ? amount : 0)}
         </c:if>
        </p>
        <c:set var="hourBegin" value="${hourPerfix}${hour}:30"></c:set>
        <c:choose>
          <c:when test="${not empty selectedSchedule and hourBegin eq selectedSchedule.occurHour and dayForSchedule eq selectedSchedule.occurDate}">
              <p class="tips color-blue">已选择</p>
          </c:when>
          <c:otherwise>
            <p class="tips ${couldAppoint ? 'color-green' : 'color-red'}">
              ${couldAppoint ? '可预约' : '已满'}
            </p>
          </c:otherwise>
        </c:choose>
      </a>
    </div>
   <%-- <li class="item-content" style="padding-left: .75rem;">
     <div class="item-inner">
       <div class="item-title-row">
         <div class="item-title" style="font-size: .8rem;"><strong>${hourPerfix}${hour}:30~${afterhourPerfix}${hour + 1}:30</strong></div>
       </div>
       <div class="item-subtitle" style="font-size: .6rem; max-height: 3rem; margin: 0px;">
         <c:if test="${currentSite.roomLimit.roomLimit > 0}">
           私人区域：${roomRecords[halfhour] == null ? 0 : roomRecords[halfhour]}/${currentSite.roomLimit.roomLimit}<br>
         </c:if>
         <c:if test="${currentSite.roomLimit.commonLimit > 0}">
           ${currentSite.fuxing ? '米域' : '公共区域' }：${commonRecords[halfhour] == null ? 0 : commonRecords[halfhour]}/${currentSite.roomLimit.commonLimit}
         </c:if>
       </div>
       <c:if test="${currentSite.roomLimit.commonLimit > 0 || currentSite.roomLimit.roomLimit > 0}">
         <div class="item-subtitle">
           <a href="#" data-hour="${hourPerfix}${hour}:30" class="booking-btn button fs-button button-fill" style="background-color: #FFDE00; color: #333; padding:.3rem .7rem; height: 1.75rem;">预约</a>
         </div>
       </c:if>
      </div>
    </li> --%>
  </c:if>
